<template>
  <div class="preView">
    <div style="font-weight: bold; margin-bottom: 10px; margin-left: 40px; margin-top: 20px;font-size: 20px;text-align: center">
      <i class="el-icon-s-data"></i>
      部门排行榜</div>
    <div class="sortView">
      <div class="numThree">
        <div class="one" >
          <span class="gradient-text">1st</span>
          <label style="font-size: 17px; font-weight: lighter;">部门：{{ deptList[0].deptName }}</label>
          <label style="font-size: 17px; font-weight: lighter;">当前积分：{{ deptList[0].totalPoints }}</label>
        </div>
        <div class="two" >
          <span class="gradient-text">2nd</span>
          <label style="font-size: 17px; font-weight: lighter;">部门：{{ deptList[1].deptName }}</label>
          <label style="font-size: 17px; font-weight: lighter;">当前积分：{{ deptList[1].totalPoints }}</label>
        </div>
        <div class="three" >
          <span class="gradient-text">3rd</span>
          <label style="font-size: 17px; font-weight: lighter;">部门：{{ deptList[2].deptName }}</label>
          <label style="font-size: 17px; font-weight: lighter;">当前积分：{{ deptList[2].totalPoints }}</label>
        </div>
      </div>

      <div class="sortItemView" v-for="(item, index) in deptList">
        <div class="line"/>
        <div class="sortItem">
          <div class="sortItemRight">
            <label style="margin-bottom: 10px; font-size: 15px; font-weight: lighter;">部门：{{ item.deptName }}</label>
            <div class="container">
              <label class="points-label">当前积分：{{ item.totalPoints }}</label>
              <el-button class="my-custom-button"  @click="pointsDeptDetailClick(item.deptId)">积分明细</el-button>
            </div>
          </div>
          <label style="margin-right: 50px; margin-left: auto; font-size: 15px; font-weight: lighter;">{{index+1}}</label>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {getAllDeptByPoints, getAllUserByPoints} from "../api/system/user";

export default {
  name: "Index",
  data() {
    return {
      mySort: null,
      deptList: []
    };
  },
  created() {
    this.getAllDeptByPoints();
  },
  methods: {
    getAllDeptByPoints() {
      getAllDeptByPoints().then(response => {
        this.deptList = response.rows;
      })
    },
    pointsDeptDetailClick(id) {
      this.$router.push({path : '/pointsDeptLog', query:{"id" : id}});
    },
  }
};
</script>

<style>
.preView {
  width: 60vw; /* 占据屏幕宽度的50% */
  margin: 0 auto; /* 居中显示 */
  padding: 20px; /* 内边距增加一些空间 */
  box-sizing: border-box; /* 包括内边距和边框 */
  background-color: #ffffff; /* 背景色可选，增加对比 */
  border-radius: 10px; /* 边框圆角 */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.numThree{
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  margin-bottom: 20px;
  margin-left: auto;
  margin-right: auto;
  width: 80%;
}
.numThree > div {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.gradient-text {
  font-size: 35px;
  font-weight: bold;
  background: linear-gradient(90deg, #126df6, #7ac5fa); /* 渐变颜色从粉红色到橙色 */
  -webkit-background-clip: text; /* 只将背景应用到文字 */
  -webkit-text-fill-color: transparent; /* 使文字填充透明，显示背景渐变 */
}
.one{
  display: flex;
  flex-direction: column;
  line-height: 2;
}
.two{
  display: flex;
  flex-direction: column;
  line-height: 2;
}
.three{
  display: flex;
  flex-direction: column;
  line-height: 2;
}
.container {
  display: flex;
  align-items: center; /* 垂直居中对齐 */
  gap: 10px; /* 控制元素之间的间距 */
}

.points-label {
  font-size: 15px;
  font-weight: lighter;
}
.my-custom-button{
  margin-left: 5px;
  font-size: 15px; /* 更改文字大小 */
  padding: 5px 5px; /* 调整内边距以改变按钮大小 */
}
.sortView {
  display: flex;
  flex-direction: column;
  background-color: white;
  margin-bottom: 30px;
  border-radius: 8px;
  width: 95%;
}
.sortTitle {
  display: flex;
  flex-direction: row;
  height: 50px;
  align-items: center;
}
.sortItemView {
  display: flex;
  flex-direction: column;
}
.sortItem {
  display: flex;
  flex-direction: row;
  align-items: center;
  margin-top: 15px;
  margin-bottom: 15px;
}
.sortItemRight {
  display: flex;
  flex-direction: column;
  margin-left: 20px;
}
.line {
  width: 95%;
  height: 0.5px;
  margin-left: 3%;
  background: #d4c4c4;
  position: relative;
  text-align: center;
}
</style>
